import os
import pandas as pd
from feature_set.app.un.app_un_gcate_v2.AppUnGCateV2 import AppUnGCateV2


class AppIdGCateV2(AppUnGCateV2):
    def __init__(self):
        super().__init__()

        self.root_dir = self.get_root_dir(os.path.abspath("."))
        self.conf_dir = os.path.join(self.root_dir, "feature_conf")
        self.google_app_cate_info = pd.read_csv(
            os.path.join(self.conf_dir, 'app', 'id', 'app_id_gcate_v2', 'google_app_cate_info.csv')
        )

    def get_root_dir(self, path):
        path_list = path.split(os.path.sep)
        index = path_list.index("featurelib")
        return os.path.sep.join(path_list[: index + 1])

    def get_issystem_app(self, data):
        data['is_system_new'] = 1-data["isSystem"]
        return data